package personal.causeless.driver.browser;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import personal.causeless.driver.drivers.BasicDriver;
import personal.causeless.driver.drivers.ExtendsDriver;

public class MyFirefox extends BasicDriver implements ExtendsDriver{
		
	public MyFirefox(String remoteAddress){
		
		try {
			driver = new RemoteWebDriver(new URL(remoteAddress), DesiredCapabilities.firefox());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
	
	public MyFirefox(){
		
		try {
			driver = new RemoteWebDriver(new URL(REMOTE_ADDRESS), DesiredCapabilities.firefox());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
	
	@SuppressWarnings("static-access")
	public MyFirefox(String browserName,String version,Platform platform,boolean jsenabled){
		
		DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
		
		desiredCapabilities.setBrowserName(browserName);
		
		desiredCapabilities.setVersion(version);
		
		desiredCapabilities.setPlatform(platform);
		
		desiredCapabilities.setJavascriptEnabled(jsenabled);
		
		try {
			driver = new RemoteWebDriver(new URL(REMOTE_ADDRESS), desiredCapabilities.firefox());
		} catch (MalformedURLException e) { 
			e.printStackTrace();
		}
		
	}

	
	@Override
	public void implicitlyWait(Integer seconds) {
		
		driver.manage().timeouts().implicitlyWait(seconds, TimeUnit.SECONDS);
		
	}

	
	@Override
	public void pageLoadTimeout(Integer seconds) {
		driver.manage().timeouts().pageLoadTimeout(seconds, TimeUnit.SECONDS);
		
	}

	
	@Override
	public void setScriptTimeout(Integer seconds) {
		driver.manage().timeouts().setScriptTimeout(seconds, TimeUnit.SECONDS);
		
	}



	@Override
	public ExtendsDriver extendsDriver() {
		
		return new MyFirefox();
	}
}
